home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
DDJMAG
/
DDJ9203.ZIP
/
XSHARP.ZIP
/
MOVEPOLY.C
< prev
next >
Wrap
Text File
|
1991-12-26
|
1KB
|
33 lines
/* Rotates and moves a polygon-based object around the three axes.
Movement is implemented only along the Z axis currently. */
#include "polygon.h"
void RotateAndMovePObject(PObject * ObjectToMove)
{
if (--ObjectToMove->RDelayCount == 0) { /* rotate */
ObjectToMove->RDelayCount = ObjectToMove->RDelayCountBase;
if (ObjectToMove->Rotate.RotateX != 0.0)
AppendRotationX(ObjectToMove->XformToWorld,
ObjectToMove->Rotate.RotateX);
if (ObjectToMove->Rotate.RotateY != 0.0)
AppendRotationY(ObjectToMove->XformToWorld,
ObjectToMove->Rotate.RotateY);
if (ObjectToMove->Rotate.RotateZ != 0.0)
AppendRotationZ(ObjectToMove->XformToWorld,
ObjectToMove->Rotate.RotateZ);
ObjectToMove->RecalcXform = 1;
}
/* Move in Z, checking for bouncing */
if (--ObjectToMove->MDelayCount == 0) {
ObjectToMove->MDelayCount = ObjectToMove->MDelayCountBase;
ObjectToMove->XformToWorld[2][3] += ObjectToMove->Move.MoveZ;
if ((ObjectToMove->XformToWorld[2][3] >
ObjectToMove->Move.MaxZ) ||
(ObjectToMove->XformToWorld[2][3] <
ObjectToMove->Move.MinZ) ) {
ObjectToMove->Move.MoveZ = -ObjectToMove->Move.MoveZ;
}
ObjectToMove->RecalcXform = 1;
}
}